﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Apilication.Common;
using Traceability.App.Domain;
using Traceability.App.DTOS;
using Traceability.ErrorCode;

namespace Traceability.App.Controllers
{

    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TraceabilityController : ControllerBase
    {
        private readonly IMediator mediator;

        public TraceabilityController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 溯源信息管理新增
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> TraceabilityHandle(CreateTraceabilityCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 溯源信息管理修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateHandle(UpdateTraceabilityCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 溯源信息管理删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> DelHandle(DelTraceabilityCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 溯源信息分页展示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaimg<TraceabilityDTO>> TraceabilityHandle([FromQuery]TraceabilityCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 商品名称下拉框
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<GoodsDTO>>> GetGoodsHandle([FromQuery]GetGoodsCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 根据生产批次查询商品信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaimg<TraceabilityDTO>> InquireTranHandle([FromQuery]InquireTranCommon request)
        {
            return mediator.Send(request);
        }


        }
}
